﻿@{
    Layout = "~/Views/Shared/PlanPartial/_LayoutEmpty.cshtml";
}

@section ScriptAndCss{
    <link href="@Url.Content("~/Content/css/plan.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/plan.js")" type="text/javascript"></script>
}

@using Wicresoft.UnifyShow.Business.Models;
@model DutyPlanModel
@{
    var canEdit = (bool)ViewData["canEdit"];
    var log = ViewData["DutyLog"] as DutyLog;
}
<div class="padding20">
    <h1 style="text-align: center;">值班记录</h1>

    <div style="border: solid 1px #95B8E7; margin: 20px 0;">
        <div class="parameter two-cols">
            <div class="parameter_name">
                日期：
            </div>
            <div class="parameter_input">
                <input type="text" disabled="disabled" value='@(Model != null ? Model.DutyDay.ToString("yyyy/MM/dd") : "")' />
            </div>
        </div>
        <div class="parameter two-cols">
            <div class="parameter_name">
                值班人员：
            </div>
            <div class="parameter_input">
                <input type="text" disabled="disabled" value='@(Model != null ? Model.WatchKeeper : "")' />
            </div>
        </div>
        @if (!canEdit)
        {
            <div class="parameter two-cols">
                <div class="parameter_name">
                    记录人员：
                </div>
                <div class="parameter_input">
                    <input type="text" disabled="disabled" value='@(log != null ? log.ModifyBy : "")' />
                </div>
            </div>
        }

        <div class="parameter">
            <div class="parameter_name">
                值班记录：
            </div>
            <div class="parameter_input">
                <textarea style="width: 86%;" @(!canEdit ? "disabled='disabled'" : "") rows="5" id="record">@(log != null ? log.DailyRecord : "")</textarea>
            </div>
        </div>
        <div class="parameter">
            <div class="parameter_name">
            </div>
            <div class="parameter_input">
                @if (canEdit)
                {
                    <input type="button" value="保存" style="width: 45px;" onclick="saveDutyLog()" />
                }
                <input type="button" value="关闭" style="width: 45px;" onclick="closeWindow();" />
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var saveDutyLog = function () {
        var record = $('#record').val();
        if (record == "") { $.messager.alert('提示', '请填写值班记录!', 'info'); return false; }

        $.post('/DutyPlan/AddDutyLog', { record: record }, function (res) {
            if (res == "OK") {
                $.messager.alert('提示', '添加成功!', 'info', function () {
                    closeWindow();
                });
            }
            if (res == "Error") {
                $.messager.alert('错误', '添加失败!', 'error');
            }

        });
    }
</script>
